﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AdvanceTimeTableManagement.Manager;

namespace AdvanceTimeTableManagement.AdminModule
{
    public partial class ClassSetUpList : Form
    {
        public bool IsUpdate { get; set; }
        public string ClassCodeToUpdate { get; set; }

        public ClassSetUpList()
        {
            InitializeComponent();
            btnShowClassList.Enabled = false;
            dataGridView1.AutoGenerateColumns = false;
            LoadData();
        }

        private void btnShowClassList_Click(object sender, EventArgs e)
        {

        }

        private void btnAddClass_Click(object sender, EventArgs e)
        {
            AdvanceTimeTableManagement.AdminModule.ClassSetUp formShow = new AdvanceTimeTableManagement.AdminModule.ClassSetUp();
            formShow.IsUpdate = false;
            formShow.Show();
            this.Hide();
        }

        public void LoadData()
        {
            using (TimeTableDataContext dataContext = new TimeTableDataContext())
            {
                dataGridView1.DataSource = dataContext.ClassSetups;
            }
        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                string code = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                ClassSetUp formShow = new ClassSetUp();
                formShow.IsUpdate = true;
                formShow.ClassCodeToUpdate = code;
                formShow.GetClassData();
                formShow.Show();
                this.Hide();
            }
        }
    }
}
